package 收集Stream流;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class test {
    public static void main(String[] args) {
        List<String> a=new ArrayList<>();
        Collections.addAll(a,"张哲峰","张叔叔","张鱼","你爹");
        Stream<String> aStream= a.stream().filter(s->s.startsWith("张"));
        //将数据流转换成集合或者数组
        List<String> b=aStream.collect(Collectors.toList());
        System.out.println(b);
        //注意流只能收集一次
        //收集成数组
        Stream<String> c=a.stream().filter(s->s.startsWith("张"));
        Object[] d=c.toArray();//toArray返回的是object类型
    }
}
